package com.example.demo.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel("统一返回类型")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Json<T> {
    @ApiModelProperty(value = "返回消息")
    private String message;
    @ApiModelProperty(value = "状态码")
    private Integer state;
    @ApiModelProperty(value = "数据")
    private T data;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Json(String message, Integer state, T data) {
        this.message = message;
        this.state = state;
        this.data = data;
    }

    public Json(T data) {
        this.data = data;
        this.state = 200;
        this.message = "success";
    }

    public Json() {
    }
}
